Current Location: Home> Function Categories> date_interval_create_from_date_string

date_interval_create_from_date_string

Alias ​​for DateInterval::createFromDateString - Set the date interval from the relative part of the string
Name:date_interval_create_from_date_string
Category:Date and time
Programming Language:php
One-line Description:Create a DateInterval from the relevant part of the string.

Definition and usage

The date_interval_create_from_date_string() function sets the DateInterval according to the relative part in the string.

Example

Use date_interval_create_from_date_string() to add 1 year and 35 days to date:

 <?php
$date = date_create ( '2019-01-01' ) ;
date_add ( $date , date_interval_create_from_date_string ( '1 year 35 days' ) ) ;
echo date_format ( $date , 'Ym-d' ) ;
?>

Try it yourself

grammar

 date_interval_create_from_date_string ( datetime )
parameter describe
datetime Required. Specify DateInterval.
Similar Functions
Popular Articles